package com.easy.customer.service;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.easy.common.bean.CustomerContacts;
import com.easy.common.service.ICustomerContactsService;
import com.easy.customer.mapper.CustomerContactsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class CustomerContactsService implements ICustomerContactsService {
    @Autowired
    CustomerContactsMapper contactMapper;

    @Override
    public CustomerContacts insert(CustomerContacts contact) {
        contactMapper.insert(contact);
        return contact;
    }

    @Override
    public CustomerContacts update(CustomerContacts contact) {
        contactMapper.updateById(contact);
        return contact;
    }

    @Override
    public int delete(Integer id) {
        int num=contactMapper.deleteById(id);
        return num;
    }

    @Override
    public int setPrimary(Integer id) {
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.set("is_primary",1);
        wrapper.eq("id",id);
        int result=contactMapper.update(wrapper);
        return result;
    }


}
